<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>arrayAscending</title>
    <script type="text/javascript">
        var arr=[3,6,81,4,0,7];
        function myFunction(arr){
            // 需要比较的轮次
            for(var i=0;i<=arr.length-1;i++){
                // 每轮需要比较的次数
                for(var j=i+1;j<=arr.length-1;j++){
                    if(arr[j]<=arr[i]){
                        var a=arr[i];
                        arr[i]=arr[j];
                        arr[j]=a;
                    }
                }
            }
            return arr;
            }
            alert(myFunction(arr));
    </script> 
</head>
    <body>
</body>
</html>